<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<jsp:include page="includes/top.jsp" />

<c:url value="index.htm" var="displayURL">
    <c:if test="${!empty param.feedId}"> <c:param name="feedId" value="${param.feedId}" /></c:if>
    <c:if test="${!empty param.categoryId}"><c:param name="categoryId" value="${param.categoryId}" /> /></c:if>
</c:url>

<c:url value="${displayURL}" var="latestURL"><c:param name="order" value="latest" /></c:url>
<c:url value="${displayURL}" var="oldestURL"><c:param name="order" value="oldest" /></c:url>
<c:url value="${displayURL}" var="likeURL"><c:param name="order" value="like" /></c:url>
<c:url value="${displayURL}" var="randomURL"><c:param name="order" value="random" /></c:url>

    <p class="order">Order feed content by <a href="<c:out value="${latestURL}" />" title="Order by latest">latest</a>, <a href="<c:out value="${oldestURL}" />" title="Order by oldest">oldest</a> or <a href="<c:out value="${likeURL}" />" title="by number of like">Like count</a> or <a href="<c:out value="${randomURL}" />" title="Randomize order">random order</a></p>

<ul>
    <c:forEach var="entry" items="${entries}">

    <li>
        <div class="entry-item-top">
            <h3><a href="${entry.uri}" target="_blank" title="${entry.title}">${entry.title}</a></h3>
            <em class="date"><fmt:formatDate value="${entry.publishedDate}" pattern="hh:mm" /> on <fmt:formatDate value="${entry.publishedDate}" pattern="EEEE" />, <fmt:formatDate value="${entry.publishedDate}" pattern="d. MMM yyyy" /></em>
        </div>
        <em>from ${entry.source.title}</em>
        <p>${entry.description.value}</p>
        <div class="control-buttons">
            <a href="feedActionHandler.htm?all=${allFeeds}&feedId=${entry.source.id}&entryId=${entry.entryID}&action=markRead" title="markRead">Read</a>
            <a href="feedActionHandler.htm?all=${allFeeds}&feedId=${entry.source.id}&entryId=${entry.entryID}&action=thumbUp" title="Thumbs up">Like</a> <span>(${entry.thumbsUp})</span>
        </div>

        <form:form modelAttribute="formComment_${entry.entryID}" action="addComment.htm" cssClass="add-comment">
            <form:textarea path="content" />
            <form:hidden path="feedEntryId" />
            <input type="submit" value="Comment" class="button" />

            <c:if test="${!empty entry.comments}">
                <ul>
                    <c:forEach var="comment" items="${entry.comments}">
                        <li>
                            <h5>${comment.user.username}</h5>
                            <p>${comment.content}</p>
                            <em class="date">at <fmt:formatDate value="${comment.publishedDate}" pattern="hh:mm" /> on <fmt:formatDate value="${comment.publishedDate}" pattern="EEEE" />, <fmt:formatDate value="${comment.publishedDate}" pattern="d. MMM yyyy" /></em>
                        </li>
                    </c:forEach>
                </ul>
            </c:if>
        </form:form>


    </li>
    </c:forEach>
</ul>

        
<jsp:include page="includes/bottom.jsp" />